#set( $symbol_pound = '#' )
#set( $symbol_dollar = '$' )
#set( $symbol_escape = '\' )
/*
 * Copyright © 2014, Finium Sdn Bhd, All Rights Reserved
 * 
 * JaxbDateSerializer.java
 * Modification History
 * *************************************************************
 * Date				Author						Comment
 * Feb 22, 2012		Venkaiah Chowdary Koneru	Created
 * *************************************************************
 */
package ${package}.support;

import java.text.ParseException;
import java.util.Date;

import javax.xml.bind.annotation.adapters.XmlAdapter;

import ${package}.AppConstants;

/**
 * Used to serialize Java.util.Date to create a custom serialize method;
 * 
 * @author Venkaiah Chowdary Koneru
 * @see XmlAdapter
 */
public class JaxbDateSerializer extends XmlAdapter<String, Date>
{
    private final ThreadSafeDateFormat dateFormat = new ThreadSafeDateFormat(
            AppConstants.MARSHALLER_OR_SERIALIZER_DATE_FORMAT);

    /**
     * converts date type to string
     * 
     * @param date
     *            date object to be converted to String
     */
    @Override
    public String marshal(Date date)
    {
        return dateFormat.format(date);
    }

    /**
     * converts string value to date object
     * 
     * @param date
     *            string date value to be converted to Date object
     */
    @Override
    public Date unmarshal(String date) throws ParseException
    {
        return dateFormat.parse(date);
    }
}
